<?php

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class LiveAdmin extends Model
{

    protected $table = 'live_admins';
    protected $fillable = ['user_id', 'site_id', 'live_id', 'module_id', 'kickout_endtime', 'speek_endtime'];

    public function getIsSpeekAttribute()
    {
        return !($this->speek_endtime < Carbon::now());
    }

    public function getIsKickOutAttribute()
    {
        return !($this->kickout_endtime < Carbon::now());
    }

    public function scopeCurrentUser($query)
    {
        $live_id=request()->input('live_id');
        return $query->where('user_id', user('id'))->where('site_id', site()['id'])->where('module_id', module()['id'])->where('live_id',$live_id);


    }
}
